function insertData(data) {
    var size = data.note.length;
    var html = "";
    for (var i = 0 ; i < size ; i++){
        html +='<div class="base-box">\n' +
            '                    <label class=" name">'+ data.note[i].username +'</label>\n' +
            '                    <div class=" info">\n' +
            '                        <label class="title">' + data.note[i].title + '</label><br><br>\n' +
            '                        <label class="message">' + data.note[i].info + '</label>\n' +
            '                    </div>\n' +
            '                    <hr style="height:3px;border:none;border-top:3px double red;"></hr>\n';
        for (var j = 0 ; j < data.note[i].reply.length ; j++){
            html +='                <div class="reply">\n' +
                '                    <label class="reply-name">' + data.note[i].reply[j].replyUsername + '</label>\n' +
                '                    <label class="reply-message">' + data.note[i].reply[j].replyInfo + '</label>\n' +
                '                </div>\n';
        }

        html +='                    <textarea class="reply-text" placeholder="请输入回复内容"></textarea><br>\n' +
            '                    <button class="reply-button">回复</button>\n' +
            '</div>\n';

    }
    console.log(html);
    $(".chat-box").html(html);
}

function getData(url) {
    $.ajax({
        type:"post",
        url:url,
        dataType:"json",
        success:function (data) {
            insertData(data);
        },
        error:function () {
            alert("数据获取失败");
        }
    });
}

$(function () {
    var data = '{"note":[' +
                            '{' +
                                '"id":1,'+
                                '"username":"发帖人名字1",' +
                                '"title":"帖子标题1",' +
                                '"info":"帖子内容1",' +
                                '"reply":[' +
                                            '{' +
                                                '"replyUsername":"回复人名字1",' +
                                                '"replyInfo":"回复内容1"' +
                                            '},' +
                                            '{' +
                                            '"replyUsername":"回复人名字2",' +
                                            '"replyInfo":"回复内容2"' +
                                            '}' +
                                        ']'+
                            '},' +
                            '{' +
                                '"id":2,'+
                                '"username":"发帖人名字2",' +
                                '"title":"帖子标题2",' +
                                '"info":"帖子内容2",' +
                                '"reply":[' +
                                            '{' +
                                                '"replyUsername":"回复人名字3",' +
                                                '"replyInfo":"回复内容3"' +
                                            '},' +
                                            '{' +
                                                '"replyUsername":"回复人名字4",' +
                                                '"replyInfo":"回复内容4"' +
                                            '}' +
                                        ']'+
                            '}' +
                        ']' +
                '}';
    // getData();
    insertData(JSON.parse(data));
})